<%@page import="java.util.ArrayList"%>
<%@page import="entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="static/bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<!-- <button class="btn btn-primary">添加</button> -->
	<%-- <a class="btn btn-primary" href="<%=request.getContextPath()%>/student_insert.jsp">添加</a> --%>
	<a class="btn btn-primary" href="<%=request.getContextPath()%>/student?method=getStudentInsertPage">添加</a>
 	<!-- 在jsp页面中可以嵌套java代码 -->
 	<%
 		// 1、将数据放到req这个内存中
 		// req.setAttribute("list", list);
 		// 在jsp页面中requst是一个内置对象，名字已经写好了
 		ArrayList<Student> list = (ArrayList<Student>)request.getAttribute("list");	
 	%>
 		<table class="table table-striped table-bordered table-hover table-condensed">
			<tr>
				<th>ID</th>
				<th>名字</th>
				<th>年龄</th>
				<th>性别</th>
				<th>班级ID</th>
				<th>删除</th>
				<th>修改</th>
			</tr>
			<%
			    for (Student student : list) {
			%>
			    	<tr>
						<td><%=student.getId()%></td>
						<td><%=student.getName()%></td>
						<td><%=student.getAge()%></td>
						<td><%=student.getGender()%></td>
						<td><%=student.getBanjiId()%></td>
						<%-- <td><a href="/Java201202/studentDelete?id=9">删除</a></td> --%>
						<%-- <td><a href="<%=request.getContextPath()%>/studentDelete?id=<%=student.getId()%>">删除</a></td> --%>
						<%-- <td><a href="<%=request.getContextPath()%>/student?method=deleteById&id=<%=student.getId()%>">删除</a></td> --%>
						<td><a href="javascript:deleteById(<%=student.getId()%>)">删除</a></td>
						<td><a href="<%=request.getContextPath()%>/student?method=selectById&id=<%=student.getId()%>">修改</a></td>
					</tr>
			<%
			    }
			%>
		</table>
		
		<!-- <nav aria-label="Page navigation">
		  <ul class="pagination">
		    <li>
		      <a href="#" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		    <li><a href="#">1</a></li>
		    <li><a href="#">2</a></li>
		    <li><a href="#">3</a></li>
		    <li><a href="#">4</a></li>
		    <li><a href="#">5</a></li>
			<li><a href="#">6</a></li>
		    <li>
		      <a href="#" aria-label="Next">
		        <span aria-hidden="true">&raquo;</span>
		      </a>
		    </li>
		  </ul>
		</nav> -->
 	
 	<script type="text/javascript">
 		function deleteById(id) {
 			var isDelete = confirm('您确认要删除么11？');
 			if (isDelete) {
 				location.href = '<%=request.getContextPath()%>/student?method=deleteById&id=' + id;
 			}
 		}
 	</script>
</body>
</html>